home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIScriptSecurityManager.idl < prev    next >
Text File  |  2006-05-08  |  11KB  |  283 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1999
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #include "nsISupports.idl"
  39. #include "nsIPrincipal.idl"
  40. #include "nsIXPCSecurityManager.idl"
  41. interface nsIURI;
  42.  
  43.  
  44. [scriptable, uuid(f4d74511-2b2d-4a14-a3e4-a392ac5ac3ff)]
  45. interface nsIScriptSecurityManager : nsIXPCSecurityManager
  46. {
  47.     ///////////////// Security Checks //////////////////
  48.     /**
  49.      * Checks whether the running script is allowed to access aProperty.
  50.      */
  51.     [noscript] void checkPropertyAccess(in JSContextPtr aJSContext,
  52.                                         in JSObjectPtr aJSObject,
  53.                                         in string aClassName,
  54.                                         in JSVal aProperty,
  55.                                         in PRUint32 aAction);
  56.  
  57.     /**
  58.      * Checks whether the running script is allowed to connect to aTargetURI
  59.      */
  60.     [noscript] void checkConnect(in JSContextPtr aJSContext,
  61.                                  in nsIURI aTargetURI,
  62.                                  in string aClassName,
  63.                                  in string aProperty);
  64.  
  65.     /**
  66.      * Check that the script currently running in context "cx" can load "uri".
  67.      *
  68.      * Will return error code NS_ERROR_DOM_BAD_URI if the load request 
  69.      * should be denied.
  70.      *
  71.      * @param cx the JSContext of the script causing the load
  72.      * @param uri the URI that is being loaded
  73.      */
  74.     [noscript] void checkLoadURIFromScript(in JSContextPtr cx, in nsIURI uri);
  75.  
  76.     /**
  77.      * Default CheckLoadURI permissions
  78.      */
  79.     // Default permissions
  80.     const unsigned long STANDARD = 0;
  81.  
  82.     // If the source is mail, disallow the load
  83.     const unsigned long DISALLOW_FROM_MAIL = 1 << 0;
  84.  
  85.     // Allow the loading of chrome URLs by non-chrome URLs
  86.     const unsigned long ALLOW_CHROME = 1 << 1;
  87.  
  88.     // Don't allow javascript: and data: URLs to load
  89.     const unsigned long DISALLOW_SCRIPT_OR_DATA = 1 << 2;
  90.  
  91.     // Don't allow javascript: URLs to load
  92.     //   WARNING: Support for this value was added in Mozilla 1.7.8 and
  93.     //   Firefox 1.0.4.  Use in prior versions WILL BE IGNORED.
  94.     const unsigned long DISALLOW_SCRIPT = 1 << 3;
  95.  
  96.     /**
  97.      * Check that content with principal aPrincipal can load "uri".
  98.      *
  99.      * Will return error code NS_ERROR_DOM_BAD_URI if the load request 
  100.      * should be denied.
  101.      *
  102.      * @param aPrincipal the URI causing the load
  103.      * @param uri the URI that is being loaded
  104.      * @param flags the permission set, see above
  105.      */
  106.     [noscript] void checkLoadURIWithPrincipal(in nsIPrincipal aPrincipal,
  107.                                               in nsIURI uri, 
  108.                                               in unsigned long flags);
  109.  
  110.     /**
  111.      * Check that content from "from" can load "uri".
  112.      *
  113.      * Will return error code NS_ERROR_DOM_BAD_URI if the load request 
  114.      * should be denied.
  115.      *
  116.      * @param from the URI causing the load
  117.      * @param uri the URI that is being loaded
  118.      * @param flags the permission set, see above
  119.      */
  120.     void checkLoadURI(in nsIURI from, in nsIURI uri, 
  121.                       in unsigned long flags);
  122.  
  123.     /**
  124.      * Same as CheckLoadURI but takes string arguments for ease of use
  125.      * by scripts
  126.      */
  127.     void checkLoadURIStr(in AUTF8String from, in AUTF8String uri, 
  128.                          in unsigned long flags);
  129.  
  130.     /**
  131.      * Check that the function 'funObj' is allowed to run on 'targetObj'
  132.      *
  133.      * Will return error code NS_ERROR_DOM_SECURITY_ERR if the function
  134.      * should not run
  135.      *
  136.      * @param cx The current active JavaScript context.
  137.      * @param funObj The function trying to run..
  138.      * @param targetObj The object the function will run on.
  139.      */
  140.     [noscript] void checkFunctionAccess(in JSContextPtr cx, in voidPtr funObj,
  141.                                         in voidPtr targetObj);
  142.  
  143.     /**
  144.      * Return true if content from the given principal is allowed to
  145.      * execute scripts.
  146.      */
  147.     [noscript] boolean canExecuteScripts(in JSContextPtr cx,
  148.                                          in nsIPrincipal principal);
  149.  
  150.     ///////////////// Principals /////////////////////// 
  151.     /**
  152.      * Return the principal of the innermost frame of the currently 
  153.      * executing script. Will return null if there is no script 
  154.      * currently executing.
  155.      */
  156.     [noscript] nsIPrincipal getSubjectPrincipal();
  157.  
  158.     /**
  159.      * Return the all-powerful system principal.
  160.      */
  161.     [noscript] nsIPrincipal getSystemPrincipal();
  162.  
  163.     /**
  164.      * Return a principal with the specified certificate fingerprint, subject
  165.      * name (the full name or concatenated set of names of the entity
  166.      * represented by the certificate), pretty name, certificate, and
  167.      * codebase URI.  The certificate fingerprint and subject name MUST be
  168.      * nonempty; otherwise an error will be thrown.  Similarly, aCert must
  169.      * not be null.
  170.      */
  171.     [noscript] nsIPrincipal
  172.          getCertificatePrincipal(in AUTF8String aCertFingerprint,
  173.                                  in AUTF8String aSubjectName,
  174.                                  in AUTF8String aPrettyName,
  175.                                  in nsISupports aCert,
  176.                                  in nsIURI aURI);
  177.  
  178.     /**
  179.      * Return a principal that has the same origin as aURI.
  180.      */
  181.     [noscript] nsIPrincipal getCodebasePrincipal(in nsIURI aURI);
  182.  
  183.     ///////////////// Capabilities API /////////////////////
  184.     /**
  185.      * Request that 'capability' can be enabled by scripts or applets
  186.      * running with 'principal'. Will prompt user if
  187.      * necessary. Returns nsIPrincipal::ENABLE_GRANTED or
  188.      * nsIPrincipal::ENABLE_DENIED based on user's choice.
  189.      */
  190.     [noscript] short requestCapability(in nsIPrincipal principal,
  191.                                        in string capability);
  192.     
  193.     /**
  194.      * Return true if the currently executing script has 'capability' enabled.
  195.      */
  196.     boolean isCapabilityEnabled(in string capability);
  197.     
  198.     /**
  199.      * Enable 'capability' in the innermost frame of the currently executing
  200.      * script.
  201.      */
  202.     void enableCapability(in string capability);
  203.  
  204.     /**
  205.      * Remove 'capability' from the innermost frame of the currently
  206.      * executing script. Any setting of 'capability' from enclosing
  207.      * frames thus comes into effect.
  208.      */
  209.     void revertCapability(in string capability);
  210.  
  211.     /**
  212.      * Disable 'capability' in the innermost frame of the currently executing
  213.      * script.
  214.      */
  215.     void disableCapability(in string capability);
  216.  
  217.     //////////////// Master Certificate Functions ////////////////////
  218.     /**
  219.      * Allow 'certificateID' to enable 'capability.' Can only be performed
  220.      * by code signed by the system certificate.
  221.      */
  222.     // XXXbz Capabilities can't have non-ascii chars?
  223.     // XXXbz ideally we'd pass a subjectName here too, and the nsISupports
  224.     // cert we're enabling for...
  225.     void setCanEnableCapability(in AUTF8String certificateFingerprint,
  226.                                 in string capability, 
  227.                                 in short canEnable);
  228.  
  229.     ///////////////////////
  230.     /**
  231.      * Return the principal of the specified object in the specified context.
  232.      */
  233.     [noscript] nsIPrincipal getObjectPrincipal(in JSContextPtr cx,
  234.                                                in JSObjectPtr obj);
  235.  
  236.     /**
  237.      * Returns true if the principal of the currently running script is the
  238.      * system principal, false otherwise.
  239.      */
  240.     [noscript] boolean subjectPrincipalIsSystem();
  241.  
  242.     /**
  243.      * Returns OK if aJSContext and target have the same "origin"
  244.      * (scheme, host, and port).
  245.      */
  246.     [noscript] void checkSameOrigin(in JSContextPtr aJSContext,
  247.                                     in nsIURI aTargetURI);
  248.  
  249.     /**
  250.      * Returns OK if aSourceURI and target have the same "origin"
  251.      * (scheme, host, and port).
  252.      */
  253.     void checkSameOriginURI(in nsIURI aSourceURI,
  254.                             in nsIURI aTargetURI);
  255.  
  256.     /**
  257.      * Returns OK if aSourcePrincipal and aTargetPrincipal
  258.      * have the same "origin" (scheme, host, and port).
  259.      */
  260.     [noscript] void checkSameOriginPrincipal(in nsIPrincipal aSourcePrincipal,
  261.                                              in nsIPrincipal aTargetPrincipal);
  262.  
  263.     /**
  264.      * Returns the principal of the global object of the given context, or null
  265.      * if no global or no principal.
  266.      */
  267.     [noscript] nsIPrincipal getPrincipalFromContext(in JSContextPtr cx);
  268.  
  269.     /**
  270.      * Utility method for comparing two URIs.  For security purposes, two URIs
  271.      * are equivalent if their schemes, hosts, and ports (if any) match.  This
  272.      * method returns true if aSubjectURI and aObjectURI have the same origin,
  273.      * false otherwise.
  274.      */
  275.     [noscript] boolean securityCompareURIs(in nsIURI aSubjectURI,
  276.                                            in nsIURI aObjectURI);
  277. };
  278.  
  279. %{C++
  280. #define NS_SCRIPTSECURITYMANAGER_CONTRACTID "@mozilla.org/scriptsecuritymanager;1"
  281. #define NS_SCRIPTSECURITYMANAGER_CLASSNAME "scriptsecuritymanager"
  282. %}
  283.